﻿// Copyright (C) 2009 Monadsphere <monadshpere@gmail.com>
//
// This file is part of Monadsphere.
//
// Monadsphere is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Monadsphere is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Monadsphere. If not, see <http://www.gnu.org/licenses/>.

using monadsphere.js;

/// <summary>
/// This namespace implements Chapter 1 of DOM Level 2 Style Specification.
/// See http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/ for details.
/// </summary>
/// 

namespace monadsphere.dom.stylesheets {

    public class StyleSheet: JSVar {

        public JSString type {
            get {
                return getProperty<JSString>("type");
            }
        }

        public JSBoolean disabled {
            get {
                return getProperty<JSBoolean>("disabled");
            }
            set {
                setProperty("disabled", value);
            }
        }

        public Node ownerNode {
            get {
                return getProperty<Node>("ownerNode");
            }
        }

        public StyleSheet parentStyleSheet {
            get {
                return getProperty<StyleSheet>("parentStyleSheet");
            }
        }

        public JSString href {
            get {
                return getProperty<JSString>("href");
            }
        }

        public JSString title {
            get {
                return getProperty<JSString>("title");
            }
        }

        public MediaList media {
            get {
                return getProperty<MediaList>("media");
            }
        }
    }

    public class StyleSheetList: JSVar {
        public JSNumber length {
            get {
                return getProperty<JSNumber>("length");
            }
        }

        public StyleSheet item(JSNumber index) {
            return callFunction<StyleSheet>("item", index);
        }

        public StyleSheet this[JSNumber index] {
            get {
                return getIndex<StyleSheet>(index);
            }
        }
    }

    public class MediaList: JSVar {
        public JSString mediaText {
            get {
                return getProperty<JSString>("mediaText");
            }
            set {
                setProperty("mediaText", value);
            }
        }

        public JSNumber length {
            get {
                return getProperty<JSNumber>("length");
            }
        }

        public JSString item(JSNumber index) {
            return callFunction<JSString>("item", index);
        }

        public JSString this[JSNumber index] {
            get {
                return getIndex<JSString>(index);
            }
        }

        public void deleteMedium(JSString oldMedium) {
            callProcedure("deleteMedium", oldMedium);
        }

        public void appendMedium(JSString newMedium) {
            callProcedure("appendMedium", newMedium);
        }
    }

    public class LinkStyle: JSVar {
        public StyleSheet sheet {
            get {
                return getProperty<StyleSheet>("sheet");
            }
        }
    }

    public class DocumentStyle: JSVar {
        public StyleSheetList styleSheets {
            get {
                return getProperty<StyleSheetList>("styleSheets");
            }
        }
    }
}
